package com.fulihui.weixinclient.request;

import com.alibaba.fastjson.JSON;
import com.fulihui.weixinclient.http.HttpMethodEnum;
import com.fulihui.weixinclient.result.OAuthUserInfoWeixinResult;

/**
 * 获取微信用户信息请求封装
 * Created by Willard on 2015/9/9.
 */
public class OAuthUserInfoWeixinRequest extends WeixinJsonRequest<OAuthUserInfoWeixinResult> {

    private static final long serialVersionUID = 8163938314085547469L;

    /* 网页授权接口调用凭证 */
    private String            access_token;

    /* 用户的唯一标识 */
    private String            openid;

    /* 返回国家地区语言版本 */
    private String            lang             = "zh_CN";

    @Override
    protected void childParam() {
        addParam("access_token", access_token);
        addParam("openid", openid);
        addParam("lang", lang);
    }

    @Override
    public String service() {
        return "https://api.weixin.qq.com/sns/userinfo";
    }

    @Override
    public String urlEndStr() {
        return null;
    }

    @Override
    public OAuthUserInfoWeixinResult parseResult(String respStr) {
        OAuthUserInfoWeixinResult result = JSON.parseObject(respStr,
            OAuthUserInfoWeixinResult.class);
        checkResult(result);
        return result;
    }

    @Override
    public HttpMethodEnum httpMethod() {
        return HttpMethodEnum.SSL_GET;
    }

    @Override
    public String requestData() {
        return null;
    }

    public void setAccess_token(String access_token) {
        this.access_token = access_token;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }

    public void setLang(String lang) {
        this.lang = lang;
    }
}
